﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ManageCourses.ascx.cs"
    Inherits="NLLSite.Administrator.UserControl.ManageCourses" %>
<%@ Register Assembly="BasicFrame.WebControls.BasicDatePicker" Namespace="BasicFrame.WebControls"
    TagPrefix="BDP" %>
<%@ Register Assembly="CKEditor.NET" Namespace="CKEditor.NET" TagPrefix="CKEditor" %>
<%@ Register Assembly="CKFinder" Namespace="CKFinder" TagPrefix="CKFinder" %>
<script runat="server" language="C#">

    // We are not using a code behind page here just for simplicity in the
    // sample file. In this way we don't have to distribute a compiled DLL for
    // this page. In real cases, the following code will instead be defined in
    // a code behind file.

    protected override void OnLoad(EventArgs e)
    {
        CKFinder.FileBrowser _FileBrowser = new CKFinder.FileBrowser();
        _FileBrowser.BasePath = "../../ckfinder/";
        _FileBrowser.SetupCKEditor(CKEditor1);
    }

</script>
<script type="text/javascript" src="../../ckfinder/ckfinder.js"></script>
<script type="text/javascript">

    function BrowseServer() {
        // You can use the "CKFinder" class to render CKFinder in a page:
        var finder = new CKFinder();
        finder.basePath = '../../ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
        finder.selectActionFunction = SetFileField;
        finder.popup();

        // It can also be done in a single line, calling the "static"
        // popup( basePath, width, height, selectFunction ) function:
        // CKFinder.popup( '../', null, null, SetFileField ) ;
        //
        // The "popup" function can also accept an object as the only argument.
        // CKFinder.popup( { basePath : '../', selectActionFunction : SetFileField } ) ;
    }

    // This is a sample function which is called when a file is selected in CKFinder.
    function SetFileField(fileUrl) {
        document.getElementById('ctl00_ContentPlaceHolderCenter_ManageCourses1_txtThumbImage').value = fileUrl;
        //Element ID = Ten class usercontrol + 1 + ID cua text box.
    }

</script>
<div class="box box-100">
    <div class="boxin">
        <div class="header">
            <h3>
                Quản lý khóa học</h3>
        </div>
        <div style="padding: 18px;">
            <!--<form class="basic" action="" method="post" enctype="multipart/form-data"><!-- Default basic forms -->
            <div class="inner-form">
                <asp:Panel ID="Panel2" runat="server" Visible="False">
                    <table>
                        <tr>
                            <td align="left" valign="top" width="160">
                                Tên khóa học:
                            </td>
                            <td align="left" valign="middle">
                                <asp:TextBox ID="txtTenKhoaHoc" runat="server" CssClass="txt" Width="250px"></asp:TextBox>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtTenKhoaHoc"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                Hình ảnh mô tả
                            </td>
                            <td align="left" valign="middle">
                                <asp:TextBox ID="txtThumbImage" runat="server" Width="177px"></asp:TextBox>
                            <input type="button" value="Browse" onclick="BrowseServer();" 
                                style="width: 96px" class="altbutton" /></td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                               Mô tả ngắn
                            </td>
                            <td align="left" valign="middle">
                                <asp:TextBox ID="txtDescription" runat="server" Height="100px" 
                                    TextMode="MultiLine" Width="442px"></asp:TextBox>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                Miêu tả khóa học:
                            </td>
                            <td align="left" valign="middle">
                                <CKEditor:CKEditorControl ID="CKEditor1" runat="server" Width="600px"></CKEditor:CKEditorControl>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="CKEditor1"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                Số lượng học viên:
                            </td>
                            <td align="left" valign="middle">
                                <asp:TextBox ID="txtSoLuong" runat="server" CssClass="txt"></asp:TextBox>
                                người&nbsp;
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtSoLuong"
                                    ErrorMessage="Nhập số" ValidationExpression="^[0-9][0-9]*$"></asp:RegularExpressionValidator>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtSoLuong"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                Ngày khai giảng:
                            </td>
                            <td align="left" valign="middle">
                                <BDP:BasicDatePicker ID="dpkBeginDate" runat="server" DisplayType="TextBox" ReadOnly="True"
                                    DateFormat="dd/MM/yyyy">
                                    <PopUpStyle BackColor="White" ForeColor="#CC0000" />
                                    <CalendarStyle BackColor="White" ForeColor="#660066" />
                                    <ButtonStyle BackColor="White" ForeColor="#660066" />
                                    <LabelStyle BackColor="White" ForeColor="#660066" />
                                    <NoneButtonStyle BackColor="White" ForeColor="#660066" />
                                    <TitleStyle BackColor="White" ForeColor="#660066" />
                                    <NextPrevStyle BackColor="White" ForeColor="#660066" />
                                    <DayHeaderStyle BackColor="White" ForeColor="#660066" />
                                    <OtherMonthDayStyle BackColor="White" ForeColor="Lime" />
                                    <DayStyle BackColor="White" ForeColor="#660066" />
                                    <WeekendDayStyle BackColor="White" ForeColor="Lime" />
                                    <SelectedDayStyle BackColor="White" ForeColor="#CC0000" />
                                    <TodayDayStyle BackColor="White" ForeColor="#000066" />
                                    <FooterStyle BackColor="White" ForeColor="#660066" />
                                    <FootNoteStyle BackColor="White" ForeColor="#660066" />
                                    <WeekNumberStyle BackColor="White" ForeColor="#CC0000" />
                                </BDP:BasicDatePicker>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="*"
                                    ControlToValidate="dpkBeginDate"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                Lịch học:
                            </td>
                            <td align="left" valign="middle">
                                <asp:TextBox ID="txtLichHoc" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtLichHoc"
                                    ErrorMessage="*"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                Giờ học:
                            </td>
                            <td align="left" valign="middle">
                                <asp:TextBox ID="txtGioHoc" runat="server"></asp:TextBox>
                            </td>
                            <td>
                                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="*"
                                    ControlToValidate="txtGioHoc"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                &nbsp;</td>
                            <td align="left" valign="middle">
                                &nbsp;</td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                Trạng thái đăng kí:
                            </td>
                            <td align="left" valign="middle">
                                <asp:CheckBox ID="CheckBox2" runat="server" />
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Hiển thị ngoài Trang chủ:&nbsp;
                                <asp:CheckBox ID="CheckBox1" runat="server" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                &nbsp;
                            </td>
                            <td align="left" valign="middle">
                                <asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label>
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                &nbsp;
                            </td>
                            <td align="left" valign="middle">
                                <asp:Button ID="btnUpdate" runat="server" Text="Lưu lại" 
                                    OnClick="btnUpdate_Click" CssClass="altbutton" />
                                <asp:Button ID="Button2" runat="server" Text="Hủy bỏ" OnClick="Button2_Click" 
                                    CssClass="altbutton" />
                            </td>
                            <td>
                                &nbsp;
                            </td>
                        </tr>
                        <tr>
                            <td align="left" valign="top" width="160">
                                &nbsp;</td>
                            <td align="left" valign="middle">
                                &nbsp;</td>
                            <td>
                                &nbsp;</td>
                        </tr>
                    </table>
                </asp:Panel>
                <asp:Panel ID="Panel1" runat="server">
                    <asp:CheckBox ID="CheckBox3" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox3_CheckedChanged" />
                    <asp:Button ID="btnXoa" runat="server" Text="Xóa" OnClick="Button1_Click" 
                        CssClass="altbutton" OnClientClick="javascript:return confirm('Tất cả học viên trong khóa học sẽ bị xóa? Bạn chắc chắn?')" />
                    <asp:Button ID="Button3" runat="server" OnClick="Button3_Click" Text="Thêm mới" 
                        CssClass="altbutton" />
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                        CellPadding="4" DataKeyNames="ID" DataSourceID="LinqDataSource1" EnableModelValidation="True"
                        ForeColor="#333333" GridLines="None" 
                        OnSelectedIndexChanged="GridView1_SelectedIndexChanged" Width="920px" 
                        AllowSorting="True">
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <Columns>
                            <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
                                SortExpression="ID" Visible="False" />
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:CheckBox ID="cbDelete" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="Name" HeaderText="Khóa học" SortExpression="Name">
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle Width="200px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Content" HeaderText="Nội dung" SortExpression="Content"
                                Visible="False">
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle Width="300px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="Quantities" HeaderText="Số lượng" SortExpression="Quantities">
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle Width="100px" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Khai Giảng">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("StartDate", "{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle Width="150px" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="Schedule" HeaderText="Lịch Học" SortExpression="Schedule">
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle Width="100px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="TimeSlot" HeaderText="Giờ học" SortExpression="TimeSlot">
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle Width="100px" />
                            </asp:BoundField>
                            <asp:CheckBoxField DataField="IsFrontPage" HeaderText="Trang chủ" SortExpression="IsFrontPage">
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle Width="100px" />
                            </asp:CheckBoxField>
                            <asp:CheckBoxField DataField="Status" HeaderText="Trạng thái" SortExpression="Status">
                                <HeaderStyle HorizontalAlign="Left" />
                                <ItemStyle Width="100px" />
                            </asp:CheckBoxField>
                            <asp:CommandField ShowSelectButton="True" SelectText="Sửa" />
                            <asp:TemplateField Visible="False">
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("Content") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="ThumbImage" Visible="False">
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("ThumbImage")%>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Description" Visible="False">
                                <ItemTemplate>
                                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("Description")%>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EditRowStyle BackColor="#999999" />
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    </asp:GridView>
                    <asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="DAL_Class.NLLDataContext"
                        TableName="Courses">
                    </asp:LinqDataSource>
                </asp:Panel>
            </div>
        </div>
    </div>
</div>
